﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ListAddress.ascx.cs"
    Inherits="Team4Mock.UserControl.Address.ListAddress" %>
<style type="text/css">
    .style1
    {
        width: 109px;
    }
    .style2
    {
        width: 104px;
    }
    .style3
    {
        width: 148px;
    }
    .button
    {
        background-color: #465c71;
        width: 80px;
        height: 26px;
        line-height: 26px;
        text-align: center;
        -webkit-border-radius: 3px;
        color: White;
    }
    .button:hover
    {
        background-color: #bfcbd6;
        color: #465c71;
    }
    #txtFirstName
    {
        width: 107px;
    }
    .style4
    {
        width: 73px;
    }
    .style5
    {
        width: 161px;
    }
</style>
<script type="text/javascript">
    function Return() {
        var Str = document.getElementsByName('select').length;
        for (var i = 0; i < document.getElementsByName('select').length; i++) {
            var a = document.getElementsByName('select').item(i).checked;
            if (a == true) {
                window.opener.document.getElementById('txtPostCode').value = document.getElementsByName('select').item(i).value;
                if (window.opener.document.getElementById('txtCounty').value != undefined) {
                    window.opener.document.getElementById('txtCounty').value = document.getElementsByName('txtCounty').item(i).value;
                }
                if (window.opener.document.getElementById('txtTown').value != undefined) {
                    window.opener.document.getElementById('txtTown').value = document.getElementsByName('txtTown').item(i).value;
                }
                window.close();
            }
        }
    }
    function Close() {
        window.close();
    }
</script>
<asp:ScriptManager runat="server" ID="script">
</asp:ScriptManager>
<fieldset style="width: 760px;">
    <legend style="height: 25px; background-color: #465c71; -webkit-border-radius: 5px 5px 0px 0px;
        color: #dde4ec; font-size: 18px;">Address Lookup</legend>
    <div style="width: 750px; margin-left: 10px;">
        <h3>
            Search PostCode</h3>
        <hr />
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td class="style1">
                    Post Code
                </td>
                <td class="style3">
                    <asp:TextBox ID="txtpostcode" runat="server" Width="115px"></asp:TextBox>
                    &nbsp;
                </td>
                <td class="style4">
                    Street
                </td>
                <td class="style5">
                    <asp:TextBox ID="txtStreet" runat="server" Width="115px"></asp:TextBox>
                </td>
                <td class="style2">
                    Town
                </td>
                <td>
                    <asp:TextBox ID="txtTown" runat="server" Width="137px"></asp:TextBox>
                </td>
            </tr>
        </table>
        <br />
        <asp:Button ID="btnSearch" runat="server" Style="width: 120px;" CssClass="button"
            Text="Search Address" OnClick="btnSearch_Click" />
        <asp:Button ID="btnNone" runat="server" CssClass="button" Text="None" OnClick="btnNone_Click" />
        <asp:Button ID="btnClear" runat="server" CssClass="button" Text="Clear" OnClick="btnClear_Click" />
        <br />
        <asp:UpdatePanel ID="pnanel" runat="server">
            <ContentTemplate>
                <p style="width: 725px; background-color: lavender; line-height: 25px; font-size: 15px;">
                    <asp:Label ID="tb" runat="server"></asp:Label>
                </p>
                <asp:GridView ID="gvAddress" AutoGenerateColumns="False" DataKeyNames="AddressID"
                    runat="server" Width="709px" Font-Size="15px" BackColor="White" BorderColor="#CCCCCC"
                    AllowSorting="true" BorderStyle="None" BorderWidth="1px" CellPadding="3">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <input type="radio" id="radio" name="select" value='<%#Eval("PostCode") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="ID" Visible="false">
                            <ItemTemplate>
                                <asp:Label ID="lbID" runat="server" Text='<%#Eval("AddressID") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Address">
                            <ItemTemplate>
                                <asp:HyperLink ID="OrgName" runat="server" Text='<%#Eval("AddressName") %>'></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Post Code">
                            <ItemTemplate>
                                <asp:Label ID="lbHOA" runat="server" Text='<%#Eval("PostCode") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Town">
                            <ItemTemplate>
                                <input type="hidden" name="txtTown" value='<%#Eval("Town") %>' />
                                <asp:Label ID="lbPostcode" runat="server" Text='<%#Eval("Town") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="County">
                            <ItemTemplate>
                                <input type="hidden" name="txtCounty" value='<%#Eval("County") %>' />
                                <asp:Label ID="lbContact" runat="server" Text='<%#Eval("County") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Country">
                            <ItemTemplate>
                                <asp:Label ID="lbActive" runat="server" Text='<%#Eval("Country") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="White" ForeColor="#000066" />
                    <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                    <RowStyle ForeColor="#000066" />
                    <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnNone" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="btnClear" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="pnanel">
        </asp:UpdateProgress>
        <br />
        <asp:Button ID="btnSelect" runat="server" OnClientClick="Return()" CssClass="button"
            Text="Select" />
        <asp:Button ID="btnClose" runat="server" CssClass="button" Text="Close" OnClientClick="Close()" />
        <br />
    </div>
</fieldset>
